#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc,char* argv[])
{

	int fd[2],cld_pid,status;

	char buf[200],len;

	puts("hello boy");

	if(pipe(fd)==-1){

		perror("create pipe error");
		exit(1);
	}

	if((cld_pid=fork())==0){

		close(fd[1]);
		len=read(fd[0],buf,sizeof(buf));
		buf[len]=0;

		printf("read data from pipe is %s ",buf);
		puts("sub proces is byby");
		exit(0);
	}else{

			close(fd[0]);

			sprintf(buf,"pPorc PID=%d create this data",cld_pid);

			write(fd[1],buf,strlen(buf));
			puts("parent proces is byby");
			exit(0);
	}
	return 0;
}